package com.shy.springframework.beans.factory.support;


import com.shy.springframework.beans.factory.exception.BeansException;
import com.shy.springframework.beans.factory.config.BeanDefinition;

public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {

    @Override
    public Object createBean(String beanName, BeanDefinition beanDefinition) {
        Object bean = null;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeansException("instantiation of bean failed");
        }
        addSingleton(beanName, bean);
        return bean;
    }
}
